from google.appengine.ext import webapp
from models.Users import *

class Image(webapp.RequestHandler):
    def get(self):
        query = D5User.all()
        query.filter("google_user = ",users.get_current_user())
        user = query.get()
        if user.avatar:
            self.response.headers['Content-Type'] = "image/png"
            self.response.out.write(user.avatar)
        else:
            self.redirect('/public/images/defaultuser.png')

class ProfileImage(webapp.RequestHandler):
    def get(self, userID):
        user = D5User.get_by_id(int(userID))
        if user.avatar:
            self.response.headers['Content-Type'] = "image/png"
            self.response.out.write(user.avatar)
        else:
            self.redirect('/public/images/defaultuser.png')
